﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using DevExpress.XtraEditors;
using DevExpress.XtraGrid.Views.Grid;
using VietGlobalSoft.Text;

namespace VietGlobalSoft.SellsManagement.App
{
    public partial class ucDanhMucKhachHang : UserControl
    {
        public ucDanhMucKhachHang()
        {
            InitializeComponent();
            this.cUSTOMERTableAdapter.Fill(this.dSSellsManagementDB.CUSTOMER);

        }


        private void datnaviMain_ButtonClick(object sender, DevExpress.XtraEditors.NavigatorButtonClickEventArgs e)
        {
            switch (e.Button.ButtonType)
            {
                case NavigatorButtonType.EndEdit:
                    this.cUSTOMERTableAdapter.Update(this.dSSellsManagementDB.CUSTOMER);
                    break;
                case NavigatorButtonType.CancelEdit:
                    if (MessageBox.Show("Bạn có chắc không?", "Cảnh báo", MessageBoxButtons.YesNo) == DialogResult.Yes)
                    {
                        this.cUSTOMERBindingSource.Remove(this.cUSTOMERBindingSource.Current);
                        this.cUSTOMERTableAdapter.Update(this.dSSellsManagementDB.CUSTOMER);
                    }
                    break;
            }
        }
       

        private void gridView1_CustomDrawRowIndicator(object sender, DevExpress.XtraGrid.Views.Grid.RowIndicatorCustomDrawEventArgs e)
        {
            if (e.RowHandle >= 0)
            {
                e.Info.DisplayText = (e.RowHandle + 1).ToString();
            }
        }

        private void gridView1_RowUpdated(object sender, DevExpress.XtraGrid.Views.Base.RowObjectEventArgs e)
        {
            this.cUSTOMERTableAdapter.Update(this.dSSellsManagementDB.CUSTOMER);
        }

        private void gridView1_InitNewRow(object sender, DevExpress.XtraGrid.Views.Grid.InitNewRowEventArgs e)
        {
            GridView view = sender as GridView;
            view.SetRowCellValue(e.RowHandle, view.Columns[0], Guid_VGS.General());
        }

        
    }
}
